package cn.zmall.search.message;

import cn.zmall.common.exception.ZmallException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

/**
 * @Author BinBini
 * @Date 2021/1/5 14:30
 * @Version 1.0
 */
public class MyMessageListener implements MessageListener {

    private final static Logger log = LoggerFactory.getLogger(MyMessageListener.class);

    @Override
    public void onMessage(Message message) {
        TextMessage textMessage = (TextMessage) message;
        try {
            String text = textMessage.getText();
            log.info(text);
        }catch (Exception e) {
            e.printStackTrace();
            throw new ZmallException("监听消息失败");
        }
    }
}
